<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript过渡</title>
</head>
<body>
<div id="example">
    <span v-if="show" transition="fade">fade</span>
    <br/>
    <button @click="show = !show">Toggle</button>
</div>
<script src="../js/vue.js"></script>
<script>
    var jsTransition = new Vue({
        el: '#example',
        data: {
            show: true
        },
        transition: {
            fade: {
                css: false,
                enter: function (el, done) {
                    //元素已被插入DOM
                    //在动画结束后调用done
                    $(el).css('opacity', 0)
                            .animate({opacity: 1}, 3000, done);
                },
                enterCancelled: function (el) {
                    $(el).stop();
                },
                leave: function (el, done) {
                    //与enter相同
                    $(el).animate({opacity: 0}, 3000, done);
                },
                leaveCancelled: function (el) {
                    $(el).stop();
                }
            }
        }
    });
    /*Vue('fade', {

    });*/
</script>
</body>
</html>